//
//  UserDTO.swift
//
//
//  Created by Jiang Chencheng on 2024/8/30.
//

import Fluent
import Vapor

struct UserDTO: Content {
    
    var id: UUID?
    var nickname: String?   // 昵称
    var email: String?      // Email
    var mood: Mood?         // 心情
    var pairCode: String?   // 配对码
    
    func toModel() -> User {
        let model = User()
        
        model.id = self.id
        if let nickname = self.nickname {
            model.nickname = nickname
        }
        if let email = self.email {
            model.email = email
        }
        if let mood = self.mood {
            model.mood = mood
        }
        
        return model
    }
}

